package com.busi.wms.controller;

import com.busi.wms.model.WmsInstorage;
import com.busi.wms.model.WmsOutstorage;
import com.jfinal.plugin.activerecord.Db;
import com.zcurd.common.util.DateUtils;
import com.zcurd.controller.BaseController;

/**
 * 报表中心
 */
public class ReportController extends BaseController {
	
	
	//月入库统计页面
	public void inStorage_monthReportPage(){
		setAttr("dictYears", WmsInstorage.me.getYears());
		setAttr("dictMonths", WmsInstorage.me.getMonths());
		render("inStorage_MonthReport.html");
	}
	//月入库统计方法
	public void inStorage_monthReport(){
		String dateTime= getPara("date_time")==null?String.valueOf(DateUtils.getThisYear()):getPara("date_time");
		renderJson(Db.find("select convert(char(8),in_time,112)  gdate,count(in_no) gcount  from wms_instorage  where convert(char(8),in_time,112) like '"+dateTime.trim() +"%' group by convert(char(8),in_time,112) "));
	}
	//月出库统计页面
	public void outStorage_monthReportPage(){
		setAttr("dictYears", WmsOutstorage.me.getYears());
		setAttr("dictMonths", WmsOutstorage.me.getMonths());
		render("outStorage_MonthReport.html");
	}
	//月出库统计方法
	public void outStorage_monthReport(){
		String dateTime= getPara("date_time")==null?String.valueOf(DateUtils.getThisYear()):getPara("date_time");
		renderJson(Db.find("select convert(char(8),out_time,112)  gdate,count(out_no) gcount  from wms_outstorage  where convert(char(8),out_time,112) like '"+dateTime.trim()+"%' group by convert(char(8),out_time,112) "));

	}
	//库存容量使用率统计，按照5000个为满盘计算
	public  void strorageNum(){
		
		renderJson(Db.find("select * from wms_capacity_statistics_v"));
	}
	//物料种类统计
	public void materialReportPage(){
		render("material_Report.html");
	}
	public  void materialReport(){
		renderJson(Db.find("select top 10  mat_name,count(mat_no) as cur_sum from wms_material group by mat_name ORDER BY cur_sum desc"));
	}
}
